package com.dmall.scf.demo

import com.dmall.scf.utils.MySQLUtils
import org.apache.spark.sql.SparkSession

/**
 * @descrption 生产Demo
 * scf
 * @author wangxuexing
 * @date 2019/12/23
 */
object SparkProdDemo {
  val CLASS_NAME = this.getClass.getSimpleName().filter(!_.equals('$'))
  def execute(args: Array[String]): Unit ={
    val spark: SparkSession = SparkSession
      .builder()
      .appName("scf")
      .enableHiveSupport()
      .getOrCreate();//激活hive支持

    val storeInfo = spark.sql(s"""SELECT WERKS AS store_code,
                                 |       NAME1 AS store_name,
                                 |       1 AS company_id,
                                 |       MANDT AS mandt,
                                 |       AREA AS area_code,
                                 |       INDU AS retail_format_code,
                                 |       INDUNAM AS retail_format_name,
                                 |       VKGRP AS group_code,
                                 |       BEZEI AS group_name,
                                 |       REGIO AS city_code,
                                 |       ORT01 AS city_name,
                                 |       PSTLZ AS postal_code,
                                 |       STRAS AS address,
                                 |       TELF1 AS tel
                                 |FROM wumart2dmall.wm_m_site limit 5""".stripMargin)
    storeInfo.show()

    MySQLUtils.overwriteMysqlData(storeInfo, "dmall_scf_test.scfc_store_info")
    spark.stop()
  }
}
